import Vue from 'vue'
import Router from 'vue-router'
import config from '@/config'
Vue.use(Router)

// 业务导航
const createRouter = () => new Router({
  mode: config.routeMode,
  base: config.routeMode === 'history' ? process.env.BASE_URL : '',
  scrollBehavior: () => ({ y: 0 }),
  routes: [{
    path: '',
    redirect: '/dashboard',
    component: () => import('@/layout/index'),
    children: [{
      path: '/dashboard',
      name: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }, {
      path: '/ability',
      name: 'ability',
      redirect: '/ability/index',
      component: () => import('@/views/ability/home'),
      children: [{
        path: 'index',
        name: 'abilityIndex',
        component: () => import('@/views/ability/index')
      }, {
        path: 'page1',
        name: 'DetailPage1',
        component: () => import('@/views/ability/page1')
      },{
        path: 'page2',
        name: 'DetailPage2',
        // component: () => import('@/views/ability/page2/index')
        component: () => import('@/views/ability/page4')
      },{
        path: 'page3',
        name: 'DetailPage3',
        component: () => import('@/views/ability/page3/index')
      }]
    }, {
      path: '/case',
      name: 'case',
      component: () => import('@/views/case/index')
    }, {
      path: '/ecology',
      name: 'ecology',
      component: () => import('@/views/ecology/index')
    }, {
      path: '/detail',
      name: 'Detail',
      redirect: '/detail/nav1',
      component: () => import('@/views/detail/index'),
      children: [{
        path: 'nav1',
        name: 'DetailNav1',
        component: () => import('@/views/detail/nav1')
      }, {
        path: 'nav2',
        name: 'DetailNav2',
        component: () => import('@/views/detail/nav2')
      }, {
        path: 'nav3',
        name: 'DetailNav3',
        component: () => import('@/views/detail/nav3')
      }, {
        path: 'nav4',
        name: 'DetailNav4',
        component: () => import('@/views/detail/nav4')
      }, {
        path: 'nav5',
        name: 'DetailNav5',
        component: () => import('@/views/detail/nav5')
      }, {
        path: 'nav6',
        name: 'DetailNav6',
        component: () => import('@/views/detail/nav6')
      }, {
        path: 'nav7',
        name: 'DetailNav7',
        component: () => import('@/views/detail/nav7')
      }, {
        path: 'nav8',
        name: 'DetailNav8',
        component: () => import('@/views/detail/nav8')
      }, {
        path: 'nav9',
        name: 'DetailNav9',
        component: () => import('@/views/detail/nav9')
      }, {
        path: 'nav10',
        name: 'DetailNav10',
        component: () => import('@/views/detail/nav10')
      }, {
        path: 'nav11',
        name: 'DetailNav11',
        component: () => import('@/views/detail/nav11')
      }, {
        path: 'nav12',
        name: 'DetailNav12',
        component: () => import('@/views/detail/nav12')
      }, {
        path: 'nav13',
        name: 'DetailNav13',
        component: () => import('@/views/detail/nav13')
      }, {
        path: 'nav14',
        name: 'DetailNav14',
        component: () => import('@/views/detail/nav14')
      }, {
        path: 'nav15',
        name: 'DetailNav15',
        component: () => import('@/views/detail/nav15')
      }, {
        path: 'nav16',
        name: 'DetailNav16',
        component: () => import('@/views/detail/nav16')
      }]
    }]
  }]
})

const router = createRouter()

// 重置路由
export const resetRouter = () => {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}

export default router
